package com.silence.ByteDance;

import java.util.ArrayList;
import java.util.List;

// SQL 代码补全
public class normal_31 {
    public static String solution(int num, String[] data, String input) {
        // Please write your code here
        List<String> res_list = new ArrayList<>();
        for (String s : data) {
            if(s.startsWith(input,0)){
                res_list.add(s);
            }
        }
        if(res_list.size()>0){
            StringBuilder res = new StringBuilder(new String());
            for (int i = 0; i < res_list.size()-1; i++) {
                res.append(res_list.get(i)).append(",");
            }
            res.append(res_list.get(res_list.size() - 1));
            return res.toString();
        }else{
            return "-1";
        }
    }

    public static void main(String[] args) {
        //  You can add more test cases here
        String[] testData1 = {"select", "from", "where", "limit", "origin_log_db", "event_log_table", "user_id", "from_mobile"};
        String[] testData2 = {"select", "from", "where", "limit", "group", "having", "in", "index", "inner", "insert", "like", "log_db", "log_table", "user_id", "group_name", "group_id"};

        System.out.println(solution(8, testData1, "f").equals("from,from_mobile"));
        System.out.println(solution(16, testData2, "g").equals("group,group_name,group_id"));
        System.out.println(solution(16, testData2, "m").equals("-1"));
    }
}
